package algorithm.dynamicProgramming.leetcode;
//292. Nim 游戏
public class CanWinNim {
    public static void main(String[] args) {
        System.out.println(canWinNim(5));

    }
    public static boolean canWinNim(int n) {
        if(n<=3){
            return true;
        }
        boolean[] f = new boolean[n+1];
        f[0]=true;
        f[1] = true;
        f[2] = true;
        f[3] =true;
        for (int i =4;i<=n;i++){
            if (!(f[i-1]&&f[i-2]&&f[i-3])){
                f[i] = true;
            }
        }
        return f[n];
    }


    public static boolean canWinNim2(int n) {
        return n%4!=0;
    }
}
